Title
%config Completer.use_jedi = False #for autocompletion feature
import pandas as pd
import numpy as np
import yfinance as yf
import datetime
%matplotlib inline
from plotly.subplots import make_subplots
import plotly.graph_objects as go
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
init_notebook_mode(connected=True)
import plotly
import plotly.io as pio
pio.templates.default = "none"
from io import BytesIO
from zipfile import ZipFile
import pandas
import requests
url = 'https://www.bis.org/statistics/full_cbpol_d_csv_row.zip'
filename = requests.get(url).content
zf = ZipFile( BytesIO(filename), 'r' )
zf.namelist()
match = [s for s in zf.namelist() if "WS_CBPOL_D_csv_row" in s][0]
df = pd.read_csv( zf.open(match) ,skiprows=lambda x: x in [0, 2])
df = df.set_index('Reference area')
df = df.iloc[7:]
df = df.astype(float)
df.fillna(method='ffill')
for i,country in enumerate(df.columns):
fig = go.Figure()
fig.add_trace(go.Scatter(
x=df[country].dropna().index,
y=df[country].dropna().values/100,
name=country,
mode="lines"))
fig.update_layout(title={'text': country}, height=400, width=900)
fig.layout.yaxis1.tickformat = ',.1%'
fig.update_xaxes(showgrid=False)
fig.update_yaxes(showgrid=False)
fig.show()